class Foo {
private:
    std::mutex mtx1,mtx2;
    unique_lock<std::mutex> lock1,lock2;
public:
    Foo() 
        :lock1(mtx1)
        ,lock2(mtx2)
    {

    }

    void first(function<void()> printFirst) {
        
        // printFirst() outputs "first". Do not change or remove this line.
        printFirst();
        lock1.unlock();
    }

    void second(function<void()> printSecond) {
        lock_guard<mutex> lg(mtx1);
        // printSecond() outputs "second". Do not change or remove this line.
        printSecond();
        lock2.unlock();
    }

    void third(function<void()> printThird) {
        lock_guard<mutex> lg(mtx2);
        // printThird() outputs "third". Do not change or remove this line.
        printThird();
    }
};
